<!--
 * @Author: g05047
 * @Date: 2021-08-26 10:43:43
 * @LastEditors: g05047
 * @LastEditTime: 2021-08-31 13:40:08
 * @Description: file content
-->
<template>
  <div class="set-table">
    <table cellspacing="0" rules="none" cellpadding="10" class="pane_right">
      <tr>
        <th>说明项</th>
        <th
          width="200px"
          v-for="it in module.functionPermissionsSettings3SaveRequestList"
          :key="it.bodyIndustry + Math.random()"
        >
          {{
            it.bodyIndustryRemarks ? it.bodyIndustryRemarks : it.bodyIndustry
          }}
        </th>
      </tr>
      <tr>
        <td>是否需要</td>
        <td
          v-for="value in module.functionPermissionsSettings3SaveRequestList"
          :key="value.bodyIndustry + Math.random()"
          align="center"
        >
          <el-radio-group v-model="value.isRequired" @change="radioChange">
            <el-radio label="1">是</el-radio>
            <el-radio label="2">否</el-radio>
          </el-radio-group>
        </td>
      </tr>
      <tr>
        <td>分值</td>
        <td
          v-for="value in module.functionPermissionsSettings3SaveRequestList"
          :key="value.bodyIndustry + Math.random()"
          align="center"
        >
          <span v-if="value.isRequired != 2">
            <el-input-number
              v-model="value.functionScore"
              v-number
              style="width: 100px;"
              :min="0"
              :max="100"
              type="number"
            ></el-input-number>

            分
          </span>
          <span v-else>--</span>
        </td>
      </tr>
      <tr>
        <td>任务频次</td>
        <td
          v-for="value in module.functionPermissionsSettings3SaveRequestList"
          :key="value.bodyIndustryId + value.moduleId"
          align="center"
        >
          <span v-if="value.isRequired != 2">
            <el-input
              v-model="value.frequencyNumber"
              style="width: 50px;"
              type="number"
              min="0"
              max="999"
            ></el-input>
            次/
            <el-select v-model="value.frequencyType" style="width:50px">
              <el-option
                v-for="item in dateOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </span>
          <span v-else>--</span>
        </td>
      </tr>
      <tr>
        <td>依据要求</td>
        <td
          :colspan="module.functionPermissionsSettings3SaveRequestList.length"
          align="center"
          :width="
            module.functionPermissionsSettings3SaveRequestList.length == 1
              ? '500px'
              : '200px'
          "
        >
          <el-input
            type="textarea"
            v-model="
              module.functionPermissionsSettings3SaveRequestList[0]
                .accordingRequirements
            "
            style="width:100%;"
            @change="requirementChange"
          ></el-input>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  props: {
    modulesList: {
      type: [Array, Object],
    },
    sort: {
      type: [Number, String],
    },
  },
  data() {
    return {
      module: this.$_.cloneDeep(this.modulesList),
      value1: '',
      dateOptions: [
        {
          label: '年',
          value: 1,
        },
        {
          label: '季度',
          value: 3,
        },
        {
          label: '月',
          value: 4,
        },
        {
          label: '工作日',
          value: 5,
        },
        {
          label: '天',
          value: 6,
        },
      ],
    };
  },
  computed: {},
  created() {
  },
  mounted() {},
  methods: {
    requirementChange(val) {
      // console.log('val: ', val);
      // if (val) {
      //   this.module.functionPermissionsSettings3SaveRequestList.forEach(
      //     item => {
      //       item.accordingRequirements = val;
      //     }
      //   );
      // }
    },
    radioChange(val) {
      console.log('val: ', val);
      let flag = this.module.functionPermissionsSettings3SaveRequestList.every(
        x => x.isRequired == '2'
      );
      console.log('flag: ', flag);
      if (flag) {
        this.$message.error('请至少选择一项！');
      }
    },
  },
};
</script>

<style scoped lang="scss">
.set-table {
  padding-left: 20px;
  table,
  tr,
  th,
  td {
    border: 1px solid #999;
  }
  ::v-deep .el-input__inner {
    padding: 0 5px;
  }
}
</style>
